<template>
  <div v-if="showMainData">
    <Collapse simple>
      <Panel name="1">
       {{$t(`module.employee.masterDataInfo`)}}
        <template #content>
          <Form :label-width="180" :disabled="disabled">
            <Row v-for="(item, index) in mainData" :gutter="32" type="flex" :key="`Row${index}`">
              <Col span="12" v-for="(child, index1) in item" :key="`Col${index}${index1}`">
                  <Form-item :prop="child.key" :label="child.label" :key="`item${index}${index1}`">
                    <div>
                      <Input
                        type="text"
                        v-model="detailList[child.key]"
                        :placeholder="showPlaceholder ? `${$t(`module.employee.enter`)}${child.label}` : ''"
                      />
                    </div>
                  </Form-item>
                </Col>
            </Row>
          </Form>
        </template>
      </Panel>
    </Collapse>
  </div>
</template>
<script>
import locales from "./locales.js";
export default {
  mixins: [locales],
  name: "CommonUserData",
  data() {
    return {
      detailList: {},
      mainData: [],
      empInfo: [
        [
          {key: "rowidObject", label: this.$t("module.employee.sysEmp.rowidObject")},
          {key: "hubStateInd", label: this.$t("module.employee.sysEmp.hubStateInd")}
        ],
        [
          {key: "createDate", label: this.$t("module.employee.sysEmp.createDate")},
          {key: "lastUpdateDate", label: this.$t("module.employee.sysEmp.lastUpdateDate")}
        ],
        [
          {key: "crcDataTime", label: this.$t("module.employee.sysEmp.crcDataTime")},
          {key: "crcRecordFlag", label: this.$t("module.employee.sysEmp.crcRecordFlag")}
        ],
        [
          {key: "empId", label: this.$t("module.employee.sysEmp.empId")},
          {key: "oprid", label: this.$t("module.employee.sysEmp.oprid")}
        ],
        [
          {key: "chnLastName", label: this.$t("module.employee.sysEmp.chnLastName")},
          {key: "chnFirstName", label: this.$t("module.employee.sysEmp.chnFirstName")}
        ],
        [
          {key: "chnName", label: this.$t("module.employee.sysEmp.chnName")},
          {key: "engName", label: this.$t("module.employee.sysEmp.engName")}
        ],
        [
          {key: "birthdate", label: this.$t("module.employee.sysEmp.birthdate")},
          {key: "birthplace", label: this.$t("module.employee.sysEmp.birthplace")}
        ],
        [
          {key: "sex", label: this.$t("module.employee.sysEmp.sex")},
          {key: "crcSexDesc", label: this.$t("module.employee.sysEmp.crcSexDesc")}
        ],
        [
          {key: "ethnicGrpCd", label: this.$t("module.employee.sysEmp.ethnicGrpCd")},
          {key: "crcEthnicgrpDesc", label: this.$t("module.employee.sysEmp.crcEthnicgrpDesc")}
        ],
        [
          {key: "marStatus", label: this.$t("module.employee.sysEmp.marStatus")},
          {key: "crcMarstatusDesc", label: this.$t("module.employee.sysEmp.crcMarstatusDesc")}
        ],
        [
          {key: "crcPoliticStatus", label: this.$t("module.employee.sysEmp.crcPoliticStatus")},
          {key: "crcPoliticDesc", label: this.$t("module.employee.sysEmp.crcPoliticDesc")}
        ],
        [
          {key: "nativePlace", label: this.$t("module.employee.sysEmp.nativePlace")},
          {key: "nationalIdType", label: this.$t("module.employee.sysEmp.nationalIdType")}
        ],
        [
          {key: "crcNidTypeDesc", label: this.$t("module.employee.sysEmp.crcNidTypeDesc")},
          {key: "certId", label: this.$t("module.employee.sysEmp.certId")}
        ],
        [
          {key: "crcOtherNidType", label: this.$t("module.employee.sysEmp.crcOtherNidType")},
          {key: "crcOtherNidNum", label: this.$t("module.employee.sysEmp.crcOtherNidNum")}
        ],
        [
          {key: "hukouTypeChn", label: this.$t("module.employee.sysEmp.hukouTypeChn")},
          {key: "crcHukoutypeDesc", label: this.$t("module.employee.sysEmp.crcHukoutypeDesc")}
        ],
        [
          {key: "crcOfficePhone", label: this.$t("module.employee.sysEmp.crcOfficePhone")},
          {key: "mobilePhone", label: this.$t("module.employee.sysEmp.mobilePhone")}
        ],
        [
          {key: "homePhone", label: this.$t("module.employee.sysEmp.homePhone")},
          {key: "crcAddrResign", label: this.$t("module.employee.sysEmp.crcAddrResign")}
        ],
        [
          {key: "crcHomeAddr", label: this.$t("module.employee.sysEmp.crcHomeAddr")},
          {key: "postal", label: this.$t("module.employee.sysEmp.postal")}
        ],
        [
          {key: "crcAddrHukou", label: this.$t("module.employee.sysEmp.crcAddrHukou")},
          {key: "emailAddr", label: this.$t("module.employee.sysEmp.emailAddr")}
        ],
        [
          {key: "crcStartDt", label: this.$t("module.employee.sysEmp.crcStartDt")},
          {key: "crcJobBgnDt", label: this.$t("module.employee.sysEmp.crcJobBgnDt")}
        ],
        [
          {key: "crcHrChannel", label: this.$t("module.employee.sysEmp.crcHrChannel")},
          {key: "crcHrChannDesc", label: this.$t("module.employee.sysEmp.crcHrChannDesc")}
        ],
        [
          {key: "contactName", label: this.$t("module.employee.sysEmp.contactName")},
          {key: "crcPhoneContact", label: this.$t("module.employee.sysEmp.crcPhoneContact")}
        ],
        [
          {key: "cpsFaxHbr", label: this.$t("module.employee.sysEmp.cpsFaxHbr")},
          {key: "crcLastNamePy", label: this.$t("module.employee.sysEmp.crcLastNamePy")}
        ],
        [
          {key: "crcFirstNamePy", label: this.$t("module.employee.sysEmp.crcFirstNamePy")},
          {key: "var1", label: this.$t("module.employee.sysEmp.var1")}
        ],
        [
          {key: "var2", label: this.$t("module.employee.sysEmp.var2")},
          {key: "var3", label: this.$t("module.employee.sysEmp.var3")}
        ],
        [
          {key: "num1", label: this.$t("module.employee.sysEmp.num1")},
          {key: "num2", label: this.$t("module.employee.sysEmp.num2")},
        ],
        [
          {key: "num3", label: this.$t("module.employee.sysEmp.num3")},
          {key: "date1", label: this.$t("module.employee.sysEmp.date1")}
        ],
        [
          {key: "date2", label: this.$t("module.employee.sysEmp.date2")},
          {key: "date3", label: this.$t("module.employee.sysEmp.date3")}
        ],
        [
          {key: "crcPhoneMobKey", label: this.$t("module.employee.sysEmp.crcPhoneMobKey")},
          {key: "crcPhoneWrkKey", label: this.$t("module.employee.sysEmp.crcPhoneWrkKey")}
        ],
        [
          {key: "crcPhoneMobile1", label: this.$t("module.employee.sysEmp.crcPhoneMobile1")},
          {key: "crcEmailPer1", label: this.$t("module.employee.sysEmp.crcEmailPer1")}
        ],
        [
          {key: "crcEmailCom1", label: this.$t("module.employee.sysEmp.crcEmailCom1")},
          {key: "extension", label: this.$t("module.employee.sysEmp.extension")}
        ],
        [
          {key: "schoolDescr", label: this.$t("module.employee.sysEmp.schoolDescr")},
          {key: "crcEducation", label: this.$t("module.employee.sysEmp.crcEducation")}
        ],
        [
          {key: "crcEduDesc", label: this.$t("module.employee.sysEmp.crcEduDesc")},
          {key: "contractNum", label: this.$t("module.employee.sysEmp.contractNum")}
        ],
        [
          {key: "contractType", label: this.$t("module.employee.sysEmp.contractType")},
          {key: "contractBeginDt", label: this.$t("module.employee.sysEmp.contractBeginDt")},
        ],
        [
          {key: "contrctExpEndDt", label: this.$t("module.employee.sysEmp.contrctExpEndDt")},
          {key: "contractEndDt", label: this.$t("module.employee.sysEmp.contractEndDt")},
        ],
        [
          {key: "cntTemplateId", label: this.$t("module.employee.sysEmp.cntTemplateId")},
          {key: "crcCntTempDesc", label: this.$t("module.employee.sysEmp.crcCntTempDesc")},
        ],
        [
          {key: "crcOperateType", label: this.$t("module.employee.sysEmp.crcOperateType")},
          {key: "crcOprtTypeDesc", label: this.$t("module.employee.sysEmp.crcOprtTypeDesc")},
        ],
          [
          {key: "crcSelcomSta", label: this.$t("module.employee.sysEmp.crcSelcomSta")},
          {key: "crcCompanyid", label: this.$t("module.employee.sysEmp.crcCompanyid")},
        ],
        [
          {key: "crcCompDescr", label: this.$t("module.employee.sysEmp.crcCompDescr")},
          {key: "gpcnTransOutdest", label: this.$t("module.employee.sysEmp.gpcnTransOutdest")},
        ],
        [
          {key: "alterEmplid", label: this.$t("module.employee.sysEmp.alterEmplid")},
          {key: "crcEmailKey", label: this.$t("module.employee.sysEmp.crcEmailKey")},
        ],
        [
          {key: "crcMajor", label: this.$t("module.employee.sysEmp.crcMajor")},
          {key: "crcEduType", label: this.$t("module.employee.sysEmp.crcEduType")},
        ],
        [
          {key: "crcStartDt1", label: this.$t("module.employee.sysEmp.crcStartDt1")},
          {key: "crcEndDt1", label: this.$t("module.employee.sysEmp.crcEndDt1")},
        ],
        [
          {key: "crcEduBakgrd", label: this.$t("module.employee.sysEmp.crcEduBakgrd")},
          {key: "crcEduBakgrdDes", label: this.$t("module.employee.sysEmp.crcEduBakgrdDes")},
        ],
        [
          {key: "crcFstEduType", label: this.$t("module.employee.sysEmp.crcFstEduType")},
          {key: "crcFstMajorDesc", label: this.$t("module.employee.sysEmp.crcFstMajorDesc")},
        ],
        [
          {key: "crcFstSchoolDes", label: this.$t("module.employee.sysEmp.crcFstSchoolDes")},
          {key: "crcBeginDt", label: this.$t("module.employee.sysEmp.crcBeginDt")},
        ],
        [
          {key: "crcEndDt", label: this.$t("module.employee.sysEmp.crcEndDt")},
          {key: "crcChgMobileDt", label: this.$t("module.employee.sysEmp.crcChgMobileDt")},
        
        ],
        [
          {key: "dataSource", label: this.$t("module.employee.sysEmp.dataSource")},
          {key: "fieldChange", label: this.$t("module.employee.sysEmp.fieldChange")},

        ]
      ],
      orgInfo: [
        [
          {key: "rowidObject", label: this.$t("module.employee.sysOrg.rowidObject")},
          {key: "hubStateInd", label: this.$t("module.employee.sysOrg.hubStateInd")}
        ],
        [
          {key: "createDate", label: this.$t("module.employee.sysOrg.createDate")},
          {key: "lastUpdateDate", label: this.$t("module.employee.sysOrg.lastUpdateDate")}
        ],
        [
          {key: "depId", label: this.$t("module.employee.sysOrg.depId")},
          {key: "depId1", label: this.$t("module.employee.sysOrg.depId1")}
        ],
        [
          {key: "processInstance", label: this.$t("module.employee.sysOrg.processInstance")},
          {key: "businessUnit", label: this.$t("module.employee.sysOrg.businessUnit")}
        ],
        [
          {key: "budescr", label: this.$t("module.employee.sysOrg.budescr")},
          {key: "descrshort", label: this.$t("module.employee.sysOrg.descrshort")}
        ],
        [
          {key: "depDesc", label: this.$t("module.employee.sysOrg.depDesc")},
          {key: "depDescshort", label: this.$t("module.employee.sysOrg.depDescshort")}
        ],
        [
          {key: "effStatus", label: this.$t("module.employee.sysOrg.effStatus")},
          {key: "effDate", label: this.$t("module.employee.sysOrg.effDate")}
        ],
        [
          {key: "crcDeptType", label: this.$t("module.employee.sysOrg.crcDeptType")},
          {key: "deptTypeDesc", label: this.$t("module.employee.sysOrg.deptTypeDesc")}
        ],
        [
          {key: "crcCompDescr", label: this.$t("module.employee.sysOrg.crcCompDescr")},
          {key: "isCompany", label: this.$t("module.employee.sysOrg.isCompany")}
        ],
        [
          {key: "crcCompanyid", label: this.$t("module.employee.sysOrg.crcCompanyid")},
          {key: "crcCostCenter", label: this.$t("module.employee.sysOrg.crcCostCenter")}
        ],
        [
          {key: "crcCostCenterNm", label: this.$t("module.employee.sysOrg.crcCostCenterNm")},
          {key: "managerId", label: this.$t("module.employee.sysOrg.managerId")}
        ],
        [
          {key: "managerName", label: this.$t("module.employee.sysOrg.managerName")},
          {key: "location", label: this.$t("module.employee.sysOrg.location")}
        ],
        [
          {key: "locationDesc", label: this.$t("module.employee.sysOrg.locationDesc")},
          {key: "crcAddress", label: this.$t("module.employee.sysOrg.crcAddress")}
        ],
        [
          {key: "postal", label: this.$t("module.employee.sysOrg.postal")},
          {key: "treeNodeNum", label: this.$t("module.employee.sysOrg.treeNodeNum")}
        ],
        [
          {key: "treeNodeNumEnd", label: this.$t("module.employee.sysOrg.treeNodeNumEnd")},
          {key: "parentNodeName", label: this.$t("module.employee.sysOrg.parentNodeName")}
        ],
        [
          {key: "parentNodeNum", label: this.$t("module.employee.sysOrg.parentNodeNum")},
          {key: "treeLevelNum", label: this.$t("module.employee.sysOrg.treeLevelNum")}
        ],
        [
          {key: "crcPdeptDescr", label: this.$t("module.employee.sysOrg.crcPdeptDescr")},
          {key: "crcPdeptDescshrt", label: this.$t("module.employee.sysOrg.crcPdeptDescshrt")}
        ],
        [
          {key: "crcDataTime", label: this.$t("module.employee.sysOrg.crcDataTime")},
          {key: "crcRecordFlag", label: this.$t("module.employee.sysOrg.crcRecordFlag")}
        ],
        [
          {key: "proAirea", label: this.$t("module.employee.sysOrg.proAirea")},
          {key: "cmCode", label: this.$t("module.employee.sysOrg.cmCode")}
        ],
        [
          {key: "kind", label: this.$t("module.employee.sysOrg.kind")},
          {key: "deptPln", label: this.$t("module.employee.sysOrg.deptPln")}
        ],
        [
          {key: "busiOrg", label: this.$t("module.employee.sysOrg.busiOrg")},
          {key: "buyOrg", label: this.$t("module.employee.sysOrg.buyOrg")}
        ],
        [
          {key: "var1", label: this.$t("module.employee.sysOrg.var1")},
          {key: "var2", label: this.$t("module.employee.sysOrg.var2")}
        ],
        [
          {key: "var3", label: this.$t("module.employee.sysOrg.var3")},
          {key: "num1", label: this.$t("module.employee.sysOrg.num1")}
        ],
        [
          {key: "num2", label: this.$t("module.employee.sysOrg.num2")},
          {key: "num3", label: this.$t("module.employee.sysOrg.num3")}
        ],
        [
          {key: "date1", label: this.$t("module.employee.sysOrg.date1")},
          {key: "date2", label: this.$t("module.employee.sysOrg.date2")}
        ],
        [
          {key: "date3", label: this.$t("module.employee.sysOrg.date3")},
          {key: "country", label: this.$t("module.employee.sysOrg.country")}
        ],
        [
          {key: "province", label: this.$t("module.employee.sysOrg.province")},
          {key: "city", label: this.$t("module.employee.sysOrg.city")}
        ],
        [
          {key: "setid", label: this.$t("module.employee.sysOrg.setid")},
          {key: "crcMdmCode", label: this.$t("module.employee.sysOrg.crcMdmCode")}
        ],
        [
          {key: "crcMdmNodeType", label: this.$t("module.employee.sysOrg.crcMdmNodeType")},
          {key: "crcMdmDepLev", label: this.$t("module.employee.sysOrg.crcMdmDepLev")}
        ],
        [
          {key: "priorDeptid", label: this.$t("module.employee.sysOrg.priorDeptid")},
          {key: "crcIsHistory", label: this.$t("module.employee.sysOrg.crcIsHistory")}
        ],
        [
          {key: "crcBusineseCode", label: this.$t("module.employee.sysOrg.crcBusineseCode")},
          {key: "crcIdssit", label: this.$t("module.employee.sysOrg.crcIdssit")}
        ],
        [
          {key: "crcIdssitDesc", label: this.$t("module.employee.sysOrg.crcIdssitDesc")},
          {key: "crcFunCd", label: this.$t("module.employee.sysOrg.crcFunCd")}
        ],
        [
          {key: "crcFunCdDesc", label: this.$t("module.employee.sysOrg.crcFunCdDesc")},
        ],
      ]

    }
  },
  props: {
    // 属性值
    userInfo: {
      type: Object,
      default: () => ({})
    },
    showMainData: {
      type: Boolean,
      default: false
    },
    dataType: {
      type: String,
      default: 'emp'
    },
    disabled: {
      type: Boolean,
      default: false
    },
    showPlaceholder: {
      type: Boolean,
      default: true
    }
  },
  watch: {
    'userInfo': {
      handler() {
        if (!this.mainData.length) {
          if (this.dataType == 'emp') {
            this.mainData = this.empInfo
          } else {
            this.mainData = this.orgInfo
          }
        
          this.mainData.flat().forEach(item => {
            this.detailList[item.key] = ''
          })
        }
        for (let key in this.detailList) {
          this.detailList[key] = this.userInfo[key] || ''
        }
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    getInfo() {
      return this.detailList
    }
  }
};
</script>